package lib.organisms;

abstract public class BasicOrganism {
    final static int JOB_NONE = -1;
    final static int JOB_WARRIOR = 0;
    final static int JOB_ASSASSIN = 1;
    final static int JOB_MAGICIAN = 2;
    final static int JOB_SHOOTER = 3;

    final static int RACE_NONE = -1;
    final static int RACE_HUMAN = 0;
    final static int RACE_ELF = 1;
    final static int RACE_MONSTER = 2;
    final static int RACE_GOD = 3;

    int blood_limit = 0;
    int blood = 0;
    boolean is_dead = false;
    int level = -1;
    int experience_limit = 0;
    int experience = 0;
    int physical_attack = 0;
    int magic_attack = 0;
    int physical_defence = 0;
    int magic_defence = 0;
    int physical_strength_limit = 0;
    int physical_strength = 0;
    int magic_strength_limit = 0;
    int magic_strength = 0;
    int job = -1;
    int race = -1;


    public void addBlood(int points) {
        this.blood += points;
        if (this.blood > this.blood_limit)
            this.blood = this.blood_limit;
    }

    public void subBlood(int points) {
        this.blood -= points;
        if (this.blood <= 0) {
            this.blood = 0;
            is_dead = true;
        }
    }

    public void resurrectToAlive()//use to resurrect yourself after the fight(if you fail
    {
        this.blood = 1;
        is_dead = false;
    }

    public boolean isDead() {
        return is_dead;
    }

    public int getLevel()
    {
        return level;
    }

    public boolean subPhysicalStrength(int points) {
        if (physical_strength < points)
            return false;
        physical_strength -= points;
        return true;
    }

    public boolean subMagicStrength(int points) {
        if (magic_strength < points)
            return false;
        magic_strength -= points;
        return true;
    }

    public String getJob() {
        switch (job) {
            case JOB_NONE:
                return "无职业";
            case JOB_WARRIOR:
                return "战士";
            case JOB_ASSASSIN:
                return "刺客";
            case JOB_MAGICIAN:
                return "法师";
            case JOB_SHOOTER:
                return "射手";
            default:
                return "Inner Error";
        }
    }

    public String getRace()
    {
        switch(race)
        {
            case RACE_NONE:
                return "无种族";
            case RACE_HUMAN:
                return "人类";
            case RACE_ELF:
                return "精灵族";
            case RACE_MONSTER:
                return "魔族";
            case RACE_GOD:
                return "神族";
            default:
                return "Inner Error";
        }
    }


}
